package com.xiaoergekeji.cloud.devops.scheduler.executor;

import org.quartz.Job;

/**
 * @program: xeg-cloud
 * @description:
 * @author: ArchieDing
 * @create: 2021-05-20 22:03
 **/
public enum ExecutorTypeEnum {
    HTTP("http", HttpExecutorJob.class),
    TOPIC("topic", TopicExecutorJob.class),
    ;
    private String type;
    private Class<? extends Job> clazz;

    ExecutorTypeEnum(String type, Class<? extends Job> clazz) {
        this.type = type;
        this.clazz = clazz;
    }

    public static String getType(Class<? extends Job> clazz) {
        for (ExecutorTypeEnum value : ExecutorTypeEnum.values()) {
            if (value.clazz.equals(clazz)) return value.type;
        }
        return HTTP.type;
    }

    public static Class<? extends Job> getClazz(String type) {
        for (ExecutorTypeEnum value : ExecutorTypeEnum.values()) {
            if (value.type.equals(type)) return value.clazz;
        }
        return HTTP.clazz;
    }
}
